<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<section class="content-header">
    <h1 style="display: inline-block">
        库存划项目标记导入
    </h1>
    <button onclick="javascript:window.history.back();" type="button" class="btn btn-success"
            style="text-align:center;vertical-align:middle;font-size:30px;position:absolute;right:14%;display: inline-block;background-color: transparent;border: none;color: #5c5c5c;outline:none;">
        <i style="-moz-transform:scaleX(-1);-webkit-transform:scaleX(-1);-o-transform:scaleX(-1);transform:scaleX(-1);filter:FlipH;"
           class="glyphicon glyphicon-share-alt"></i><span
            style="margin-left: 5px;font-size: 16px;position: absolute;top: 20%;">返回到库存划项目申请页面</span>
    </button>
</section>
<section class="content">
    <form id="form">
        <div class="row">
            <div class="col-md-6 col-md-offset-3">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">Excel信息导入</h3>
                    </div>
                    <div class="box-body">
                        <div class="form-group">
                            <label>库存下载</label>
                            <a id="stockExport" th:href="@{/half/halInvManage/invToProMark/inventoryExport}">点击下载</a>
                        </div>
                        <div class="form-group">
                            <label>15天内导入错误数据</label>
                            <a id="download-error" th:href="@{/half/halInvManage/invToProMark/errorExport}">点击下载</a>
                            <p class="help-block">如果错误数据已经处理，请忽略！</p>
                        </div>
                        <div class="form-group">
                            <label for="upload_file">选择Excel文件并上传</label>
                            <input type="file" multiple="multiple" id="upload_file" name="file">

                            <p class="help-block">上传文档从第二行开始导入，请按格式要求整理，有‘禁改’字样列的信息不允许修改，否则将导致导入失败！</p>
                        </div>
                    </div>
                    <div class="box-footer">
                        <p class="text-red">只导入标记数据且导入之前请确认导入信息准确无误！</p>
                        <button id="btn-upload" type="button" class="btn btn-primary">上传</button>
                    </div>
                </div>
            </div>
        </div>
    </form>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    /** 验证 */
    js.validate.init("form", {
        fields: {
            file: {
                validators: {
                    notEmpty: {message: '上传文件不能为空'},
                    file: {extension: 'xls,xlsx', message: '请选择excel文件'}
                }
            }
        }
    });


    /** 上传文件 */
    $("#btn-upload").click(function () {
        js.validSubmit({
            formId: "form",
            url: ctx + "half/halInvManage/invToProMark/importFile",
            data: new FormData($("#form")[0]),
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    js.modal.success(result.msg);
                } else {
                    js.modal.warning("部分数据导入失败，请下载错误数据。");
                }
                js.modal.closeLoading();
            },
            error: function () {
                js.modal.warning("部分数据导入失败，请下载错误数据。");
                js.modal.closeLoading();
            }
        });
    });

</script>
</body>
</html>
